<?php

namespace App\Http\Controllers\Third\OceanEngine;

use App\Http\Controllers\BaseController;
use App\Http\Validate\Third\OceanEngine\OceanEngineValidate;
use App\Service\Third\OceanEngine\OceanEngineService;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class OceanEngineController extends BaseController
{
    /**
     * 巨量引擎 授权码回调
     *
     * @param Request $request
     * @return JsonResponse
     * @throws GuzzleException
     * @throws ValidationException
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function oauth(Request $request): JsonResponse
    {
        $params = OceanEngineValidate::oauthValidate($request->all());
        OceanEngineService::generateAuthToken($params->auth_code);
        return self::success();
    }
}
